{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "#  Lasso and Ridge Regression"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "# yahoo finance is used to fetch data \n",
        "import yfinance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:39.017Z",
          "iopub.execute_input": "2022-11-20T04:19:39.022Z",
          "iopub.status.idle": "2022-11-20T04:19:39.480Z",
          "shell.execute_reply": "2022-11-20T04:19:39.500Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2014-01-01'\n",
        "end = '2019-01-01'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View Columns\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 completed\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 2,
          "data": {
            "text/plain": "                           Open  High   Low  Close  Adj Close    Volume\nDate                                                                   \n2014-01-02 00:00:00-05:00  3.85  3.98  3.84   3.95       3.95  20548400\n2014-01-03 00:00:00-05:00  3.98  4.00  3.88   4.00       4.00  22887200\n2014-01-06 00:00:00-05:00  4.01  4.18  3.99   4.13       4.13  42398300\n2014-01-07 00:00:00-05:00  4.19  4.25  4.11   4.18       4.18  42932100\n2014-01-08 00:00:00-05:00  4.23  4.26  4.14   4.18       4.18  30678700",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02 00:00:00-05:00</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n    </tr>\n    <tr>\n      <th>2014-01-03 00:00:00-05:00</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n    </tr>\n    <tr>\n      <th>2014-01-06 00:00:00-05:00</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n    </tr>\n    <tr>\n      <th>2014-01-07 00:00:00-05:00</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n    </tr>\n    <tr>\n      <th>2014-01-08 00:00:00-05:00</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:39.489Z",
          "iopub.execute_input": "2022-11-20T04:19:39.492Z",
          "iopub.status.idle": "2022-11-20T04:19:40.180Z",
          "shell.execute_reply": "2022-11-20T04:19:40.196Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset['Open_Close'] = (dataset['Open'] - dataset['Adj Close'])/dataset['Open']\n",
        "dataset['High_Low'] = (dataset['High'] - dataset['Low'])/dataset['Low']\n",
        "dataset['Increase_Decrease'] = np.where(dataset['Volume'].shift(-1) > dataset['Volume'],1,0)\n",
        "dataset['Buy_Sell_on_Open'] = np.where(dataset['Open'].shift(-1) > dataset['Open'],1,0)\n",
        "dataset['Buy_Sell'] = np.where(dataset['Adj Close'].shift(-1) > dataset['Adj Close'],1,0)\n",
        "dataset['Returns'] = dataset['Adj Close'].pct_change()\n",
        "dataset = dataset.dropna()\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 3,
          "data": {
            "text/plain": "                           Open  High   Low  Close  Adj Close    Volume  \\\nDate                                                                      \n2014-01-03 00:00:00-05:00  3.98  4.00  3.88   4.00       4.00  22887200   \n2014-01-06 00:00:00-05:00  4.01  4.18  3.99   4.13       4.13  42398300   \n2014-01-07 00:00:00-05:00  4.19  4.25  4.11   4.18       4.18  42932100   \n2014-01-08 00:00:00-05:00  4.23  4.26  4.14   4.18       4.18  30678700   \n2014-01-09 00:00:00-05:00  4.20  4.23  4.05   4.09       4.09  30667600   \n\n                           Open_Close  High_Low  Increase_Decrease  \\\nDate                                                                 \n2014-01-03 00:00:00-05:00   -0.005025  0.030928                  1   \n2014-01-06 00:00:00-05:00   -0.029925  0.047619                  1   \n2014-01-07 00:00:00-05:00    0.002387  0.034063                  0   \n2014-01-08 00:00:00-05:00    0.011820  0.028986                  0   \n2014-01-09 00:00:00-05:00    0.026190  0.044444                  0   \n\n                           Buy_Sell_on_Open  Buy_Sell   Returns  \nDate                                                             \n2014-01-03 00:00:00-05:00                 1         1  0.012658  \n2014-01-06 00:00:00-05:00                 1         1  0.032500  \n2014-01-07 00:00:00-05:00                 1         0  0.012106  \n2014-01-08 00:00:00-05:00                 0         0  0.000000  \n2014-01-09 00:00:00-05:00                 0         1 -0.021531  ",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>Open_Close</th>\n      <th>High_Low</th>\n      <th>Increase_Decrease</th>\n      <th>Buy_Sell_on_Open</th>\n      <th>Buy_Sell</th>\n      <th>Returns</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-03 00:00:00-05:00</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>-0.005025</td>\n      <td>0.030928</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.012658</td>\n    </tr>\n    <tr>\n      <th>2014-01-06 00:00:00-05:00</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>-0.029925</td>\n      <td>0.047619</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.032500</td>\n    </tr>\n    <tr>\n      <th>2014-01-07 00:00:00-05:00</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>0.002387</td>\n      <td>0.034063</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.012106</td>\n    </tr>\n    <tr>\n      <th>2014-01-08 00:00:00-05:00</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>0.011820</td>\n      <td>0.028986</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>2014-01-09 00:00:00-05:00</th>\n      <td>4.20</td>\n      <td>4.23</td>\n      <td>4.05</td>\n      <td>4.09</td>\n      <td>4.09</td>\n      <td>30667600</td>\n      <td>0.026190</td>\n      <td>0.044444</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.021531</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 3,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.186Z",
          "iopub.execute_input": "2022-11-20T04:19:40.189Z",
          "shell.execute_reply": "2022-11-20T04:19:40.209Z",
          "iopub.status.idle": "2022-11-20T04:19:40.213Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Create Labels string\n",
        "dataset['Increase_Decrease_L'] = np.where(dataset['Volume'].shift(-1) > dataset['Volume'],'Increase','Decrease')\n",
        "dataset['Buy_Sell_on_Open_L'] = np.where(dataset['Open'].shift(-1) > dataset['Open'],'Buy','Sell')\n",
        "dataset['Buy_Sell_L'] = np.where(dataset['Adj Close'].shift(-1) > dataset['Adj Close'],'Buy','Sell')\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 4,
          "data": {
            "text/plain": "                           Open  High   Low  Close  Adj Close    Volume  \\\nDate                                                                      \n2014-01-03 00:00:00-05:00  3.98  4.00  3.88   4.00       4.00  22887200   \n2014-01-06 00:00:00-05:00  4.01  4.18  3.99   4.13       4.13  42398300   \n2014-01-07 00:00:00-05:00  4.19  4.25  4.11   4.18       4.18  42932100   \n2014-01-08 00:00:00-05:00  4.23  4.26  4.14   4.18       4.18  30678700   \n2014-01-09 00:00:00-05:00  4.20  4.23  4.05   4.09       4.09  30667600   \n\n                           Open_Close  High_Low  Increase_Decrease  \\\nDate                                                                 \n2014-01-03 00:00:00-05:00   -0.005025  0.030928                  1   \n2014-01-06 00:00:00-05:00   -0.029925  0.047619                  1   \n2014-01-07 00:00:00-05:00    0.002387  0.034063                  0   \n2014-01-08 00:00:00-05:00    0.011820  0.028986                  0   \n2014-01-09 00:00:00-05:00    0.026190  0.044444                  0   \n\n                           Buy_Sell_on_Open  Buy_Sell   Returns  \\\nDate                                                              \n2014-01-03 00:00:00-05:00                 1         1  0.012658   \n2014-01-06 00:00:00-05:00                 1         1  0.032500   \n2014-01-07 00:00:00-05:00                 1         0  0.012106   \n2014-01-08 00:00:00-05:00                 0         0  0.000000   \n2014-01-09 00:00:00-05:00                 0         1 -0.021531   \n\n                          Increase_Decrease_L Buy_Sell_on_Open_L Buy_Sell_L  \nDate                                                                         \n2014-01-03 00:00:00-05:00            Increase                Buy        Buy  \n2014-01-06 00:00:00-05:00            Increase                Buy        Buy  \n2014-01-07 00:00:00-05:00            Decrease                Buy       Sell  \n2014-01-08 00:00:00-05:00            Decrease               Sell       Sell  \n2014-01-09 00:00:00-05:00            Decrease               Sell        Buy  ",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>Open_Close</th>\n      <th>High_Low</th>\n      <th>Increase_Decrease</th>\n      <th>Buy_Sell_on_Open</th>\n      <th>Buy_Sell</th>\n      <th>Returns</th>\n      <th>Increase_Decrease_L</th>\n      <th>Buy_Sell_on_Open_L</th>\n      <th>Buy_Sell_L</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-03 00:00:00-05:00</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>-0.005025</td>\n      <td>0.030928</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.012658</td>\n      <td>Increase</td>\n      <td>Buy</td>\n      <td>Buy</td>\n    </tr>\n    <tr>\n      <th>2014-01-06 00:00:00-05:00</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>-0.029925</td>\n      <td>0.047619</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.032500</td>\n      <td>Increase</td>\n      <td>Buy</td>\n      <td>Buy</td>\n    </tr>\n    <tr>\n      <th>2014-01-07 00:00:00-05:00</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>0.002387</td>\n      <td>0.034063</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.012106</td>\n      <td>Decrease</td>\n      <td>Buy</td>\n      <td>Sell</td>\n    </tr>\n    <tr>\n      <th>2014-01-08 00:00:00-05:00</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>0.011820</td>\n      <td>0.028986</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.000000</td>\n      <td>Decrease</td>\n      <td>Sell</td>\n      <td>Sell</td>\n    </tr>\n    <tr>\n      <th>2014-01-09 00:00:00-05:00</th>\n      <td>4.20</td>\n      <td>4.23</td>\n      <td>4.05</td>\n      <td>4.09</td>\n      <td>4.09</td>\n      <td>30667600</td>\n      <td>0.026190</td>\n      <td>0.044444</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.021531</td>\n      <td>Decrease</td>\n      <td>Sell</td>\n      <td>Buy</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 4,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.220Z",
          "iopub.execute_input": "2022-11-20T04:19:40.225Z",
          "iopub.status.idle": "2022-11-20T04:19:40.234Z",
          "shell.execute_reply": "2022-11-20T04:19:40.274Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = dataset[['Open', 'High', 'Low', 'Volume']].values\n",
        "y = dataset['Adj Close'].values"
      ],
      "outputs": [],
      "execution_count": 5,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.239Z",
          "iopub.execute_input": "2022-11-20T04:19:40.243Z",
          "iopub.status.idle": "2022-11-20T04:19:40.249Z",
          "shell.execute_reply": "2022-11-20T04:19:40.277Z"
        }
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Lasso"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.linear_model import Lasso\n",
        "from sklearn.model_selection import GridSearchCV\n",
        "\n",
        "lasso = Lasso()\n",
        "parameters = {'alpha': [1e-15, 1e-10, 1e-8, 1e-4, 1e-3,1e-2, 1, 5, 10, 20]}\n",
        "lasso_regressor = GridSearchCV(lasso, parameters, scoring='neg_mean_squared_error', cv = 5)\n",
        "lasso_regressor.fit(X, y)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 6,
          "data": {
            "text/plain": "GridSearchCV(cv=5, error_score=nan,\n             estimator=Lasso(alpha=1.0, copy_X=True, fit_intercept=True,\n                             max_iter=1000, normalize=False, positive=False,\n                             precompute=False, random_state=None,\n                             selection='cyclic', tol=0.0001, warm_start=False),\n             iid='deprecated', n_jobs=None,\n             param_grid={'alpha': [1e-15, 1e-10, 1e-08, 0.0001, 0.001, 0.01, 1,\n                                   5, 10, 20]},\n             pre_dispatch='2*n_jobs', refit=True, return_train_score=False,\n             scoring='neg_mean_squared_error', verbose=0)"
          },
          "metadata": {}
        }
      ],
      "execution_count": 6,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.255Z",
          "iopub.execute_input": "2022-11-20T04:19:40.259Z",
          "iopub.status.idle": "2022-11-20T04:19:40.672Z",
          "shell.execute_reply": "2022-11-20T04:19:40.667Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "lasso_regressor.best_params_"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 7,
          "data": {
            "text/plain": "{'alpha': 1e-15}"
          },
          "metadata": {}
        }
      ],
      "execution_count": 7,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.676Z",
          "iopub.execute_input": "2022-11-20T04:19:40.680Z",
          "iopub.status.idle": "2022-11-20T04:19:40.688Z",
          "shell.execute_reply": "2022-11-20T04:19:40.732Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "lasso_regressor.best_score_"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 8,
          "data": {
            "text/plain": "-0.05075320454462316"
          },
          "metadata": {}
        }
      ],
      "execution_count": 8,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.695Z",
          "iopub.execute_input": "2022-11-20T04:19:40.699Z",
          "iopub.status.idle": "2022-11-20T04:19:40.707Z",
          "shell.execute_reply": "2022-11-20T04:19:40.737Z"
        }
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Ridge"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.linear_model import Ridge\n",
        "\n",
        "alpha = [1e-15, 1e-10, 1e-8, 1e-4, 1e-3,1e-2, 1, 5, 10, 20]\n",
        "ridge = Ridge()\n",
        "\n",
        "parameters = {'alpha': [1e-15, 1e-10, 1e-8, 1e-4, 1e-3,1e-2, 1, 5, 10, 20]}\n",
        "ridge_regressor = GridSearchCV(ridge, parameters,scoring='neg_mean_squared_error', cv=5)\n",
        "ridge_regressor.fit(X, y)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 9,
          "data": {
            "text/plain": "GridSearchCV(cv=5, error_score=nan,\n             estimator=Ridge(alpha=1.0, copy_X=True, fit_intercept=True,\n                             max_iter=None, normalize=False, random_state=None,\n                             solver='auto', tol=0.001),\n             iid='deprecated', n_jobs=None,\n             param_grid={'alpha': [1e-15, 1e-10, 1e-08, 0.0001, 0.001, 0.01, 1,\n                                   5, 10, 20]},\n             pre_dispatch='2*n_jobs', refit=True, return_train_score=False,\n             scoring='neg_mean_squared_error', verbose=0)"
          },
          "metadata": {}
        }
      ],
      "execution_count": 9,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.713Z",
          "iopub.execute_input": "2022-11-20T04:19:40.717Z",
          "shell.execute_reply": "2022-11-20T04:19:40.757Z",
          "iopub.status.idle": "2022-11-20T04:19:40.763Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "ridge_regressor.best_params_"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 10,
          "data": {
            "text/plain": "{'alpha': 1e-15}"
          },
          "metadata": {}
        }
      ],
      "execution_count": 10,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.768Z",
          "iopub.execute_input": "2022-11-20T04:19:40.774Z",
          "iopub.status.idle": "2022-11-20T04:19:40.785Z",
          "shell.execute_reply": "2022-11-20T04:19:40.811Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "ridge_regressor.best_score_"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 11,
          "data": {
            "text/plain": "-0.02182416487509722"
          },
          "metadata": {}
        }
      ],
      "execution_count": 11,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-11-20T04:19:40.791Z",
          "iopub.execute_input": "2022-11-20T04:19:40.796Z",
          "iopub.status.idle": "2022-11-20T04:19:40.804Z",
          "shell.execute_reply": "2022-11-20T04:19:40.814Z"
        }
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.6.13",
      "mimetype": "text/x-python",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "file_extension": ".py"
    },
    "kernelspec": {
      "name": "python3",
      "language": "python",
      "display_name": "Python 3"
    },
    "nteract": {
      "version": "0.28.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}